import path from "path";
import Koa from "koa";
import KoaStatic from "koa-static";
import mount from "koa-mount";
import { getRouter, IAuthOptions } from "./router";
import { jwtAuth } from "./controller";

function uniAuth(app: Koa, options: IAuthOptions) {
  const auth = new Koa();
  const router = getRouter(options);
  auth.use(KoaStatic(path.resolve(__dirname, "./public")));
  auth.use(router.routes());
  app.use(mount("/auth", auth));
}

export { jwtAuth, uniAuth };
